#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <iostream>

using namespace std;
////查看进程
//int main()
//{
//    while(1)
//    {
//        cout << "processing..." <<endl;
//        sleep(1);
//    }
//}

int main()
{
    printf("当前进程：%d\n",getpid());
    pid_t id = fork();

    if(id == 0)
    {
        printf("子进程：%d\n",getpid());
        sleep(1);
    }
    else if(id >= 0)
    {
        printf("父进程：%d\n",getpid());
        sleep(1);
    }
    else
    {
        printf("error");
        sleep(1);
    }
}
